home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / pcl-rev4.lha / kcl-mods.text < prev    next >
Text File  |  1990-05-01  |  8KB  |  221 lines

  1.  
  2. (1) Turbo closure patch
  3.  
  4. To make the turbo closure stuff work, make the following changes to KCL.
  5. These changes can also work for an IBCL.
  6.  
  7. The three patches in this file add two features (reflected in the
  8. value of *features*) to your KCL or IBCL:
  9.   a feature named :TURBO-CLOSURE which increases the speed of the
  10.      code generated by FUNCALLABLE-INSTANCE-DATA-1
  11.      (previous versions of the file kcl-mods.text had this feature only), 
  12. and
  13.   a feature named :TURBO-CLOSURE-ENV-SIZE which increases the speed
  14.      of the function FUNCALLABLE-INSTANCE-P.
  15.  
  16. (This file comprises two features rather than just one to allow the
  17. PCL system to be work in KCL systems that do not have this patch,
  18. or that have the old version of this patch.)
  19.  
  20.  
  21. The first of these patches changes the turbo_closure function to
  22. store the size of the environment in the turbo structure.
  23.  
  24. The second of patch fixes a garbage-collector bug in which
  25. the turbo structure was sometimes ignored, AND also adapts
  26. the garbage-collector to conform to the change made in the
  27. first patch.  The bug has been fixed in newer versions of
  28. AKCL, but it is still necessary to apply this patch, if the
  29. first and third patches are applied.
  30.  
  31. The third change pushes :turbo-closure and :turbo-closure-env-size
  32. on the *features* list so that PCL will know that turbo closures 
  33. are enabled.
  34.  
  35.  
  36. Note that these changes have to be made before PCL is compiled, and a
  37. PCL which is compiled in a KCL/IBCL with these changes can only be run
  38. in a KCL/IBCL with these changes.
  39.  
  40. (1-1) edit the function turbo_closure in the file kcl/c/cfun.c,
  41. change the lines
  42. ----------
  43. turbo_closure(fun)
  44. object fun;
  45. {
  46.         object l;
  47.         int n;
  48.  
  49.         for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  50.                 ;
  51.         fun->cc.cc_turbo = (object *)alloc_contblock(n*sizeof(object));
  52.         for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  53.                 fun->cc.cc_turbo[n] = l;
  54. }
  55. ----------
  56. to
  57. ----------
  58. turbo_closure(fun)
  59. object fun;
  60. {
  61.   object l,*block;
  62.   int n;
  63.  
  64.   if(fun->cc.cc_turbo==NULL)
  65.     {for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr);
  66.      block=(object *)alloc_contblock((1+n)*sizeof(object));
  67.      *block=make_fixnum(n);
  68.      fun->cc.cc_turbo = block+1; /* equivalent to &block[1] */
  69.      for (n = 0, l = fun->cc.cc_env;  !endp(l);  n++, l = l->c.c_cdr)
  70.        fun->cc.cc_turbo[n] = l;}
  71. }
  72. ----------
  73.  
  74.  
  75. (1-2) edit the function mark_object in the file kcl/c/gbc.c,
  76. Find the lines following case t_cclosure: in mark_object.
  77. If they look like the ones between the lines marked (KCL),
  78. make the first change, but if the look like the lines marked
  79. (AKCL), apply the second change instead, and if the file
  80. sgbc.c exists, apply the third change to it.
  81. (1-2-1) Change:
  82. (KCL)----------
  83.         case t_cclosure:
  84.                 mark_object(x->cc.cc_name);
  85.                 mark_object(x->cc.cc_env);
  86.                 mark_object(x->cc.cc_data);
  87.                 if (x->cc.cc_start == NULL)
  88.                         break;
  89.                 if (what_to_collect == t_contiguous) {
  90.                         if (get_mark_bit((int *)(x->cc.cc_start)))
  91.                                 break;
  92.                         mark_contblock(x->cc.cc_start, x->cc.cc_size);
  93.                         if (x->cc.cc_turbo != NULL) {
  94.                                 for (i = 0, y = x->cc.cc_env;
  95.                                      type_of(y) == t_cons;
  96.                                      i++, y = y->c.c_cdr);
  97.                                 mark_contblock((char *)(x->cc.cc_turbo),
  98.                                                i*sizeof(object));
  99.                         }
  100.                 }
  101.                 break;
  102. (KCL)----------
  103. to
  104. (KCL new)----------
  105.         case t_cclosure:
  106.                 mark_object(x->cc.cc_name);
  107.                 mark_object(x->cc.cc_env);
  108.                 mark_object(x->cc.cc_data);
  109.                 if (what_to_collect == t_contiguous)
  110.                         if (x->cc.cc_turbo != NULL) {
  111.                                 mark_contblock((char *)(x->cc.cc_turbo-1),
  112.                                                (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  113.                         }
  114.                 if (x->cc.cc_start == NULL)
  115.                         break;
  116.                 if (what_to_collect == t_contiguous) {
  117.                         if (get_mark_bit((int *)(x->cc.cc_start)))
  118.                                 break;
  119.                         mark_contblock(x->cc.cc_start, x->cc.cc_size);
  120.                 }
  121.                 break;
  122. (KCL new)----------
  123. (1-2-2) Or, Change:
  124. (AKCL)----------
  125.         case t_cclosure:
  126.                 mark_object(x->cc.cc_name);
  127.                 mark_object(x->cc.cc_env);
  128.                 mark_object(x->cc.cc_data);
  129.                 if (what_to_collect == t_contiguous) {
  130.                   if (x->cc.cc_turbo != NULL) {
  131.                     for (i = 0, y = x->cc.cc_env;
  132.                          type_of(y) == t_cons;
  133.                          i++, y = y->c.c_cdr);
  134.                     mark_contblock((char *)(x->cc.cc_turbo),
  135.                                                i*sizeof(object));
  136.                         }
  137.                 }
  138.                 break;
  139. (AKCL)----------
  140. To:
  141. (AKCL new)----------
  142.         case t_cclosure:
  143.                 mark_object(x->cc.cc_name);
  144.                 mark_object(x->cc.cc_env);
  145.                 mark_object(x->cc.cc_data);
  146.                 if (what_to_collect == t_contiguous) {
  147.                   if (x->cc.cc_turbo != NULL)
  148.                     mark_contblock((char *)(x->cc.cc_turbo-1),
  149.                                    (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  150.                 }
  151.                 break;
  152. (AKCL new)----------
  153. (1-2-3) In sgbc.c (if it exists), Change:
  154. (AKCL)----------
  155.         case t_cclosure:
  156.                 sgc_mark_object(x->cc.cc_name);
  157.                 sgc_mark_object(x->cc.cc_env);
  158.                 sgc_mark_object(x->cc.cc_data);
  159.                 if (what_to_collect == t_contiguous) {
  160.                   if (x->cc.cc_turbo != NULL) {
  161.                     for (i = 0, y = x->cc.cc_env;
  162.                          type_of(y) == t_cons;
  163.                          i++, y = y->c.c_cdr);
  164.                     mark_contblock((char *)(x->cc.cc_turbo),
  165.                                                i*sizeof(object));
  166.                         }
  167.                 }
  168.                 break;
  169. (AKCL)----------
  170. To:
  171. (AKCL new)----------
  172.         case t_cclosure:
  173.                 sgc_mark_object(x->cc.cc_name);
  174.                 sgc_mark_object(x->cc.cc_env);
  175.                 sgc_mark_object(x->cc.cc_data);
  176.                 if (what_to_collect == t_contiguous) {
  177.                   if (x->cc.cc_turbo != NULL)
  178.                     mark_contblock((char *)(x->cc.cc_turbo-1),
  179.                                    (1+fix(*(x->cc.cc_turbo-1)))*sizeof(object));
  180.                 }
  181.                 break;
  182. (AKCL new)----------
  183.  
  184.  
  185. (1-3) edit the function init_main in the file kcl/c/main.c,
  186. change the lines where setting the value of *features* to add a :turbo-closure
  187. and a :turbo-closure-env-size into the list in your KCL/IBCL.
  188.  
  189. For example, in Sun4(SunOS) version of IBCL
  190. changing the lines:
  191. ----------
  192.         make_special("*FEATURES*",
  193.                      make_cons(make_ordinary("SUN4"),
  194.                      make_cons(make_ordinary("SPARC"),
  195.                      make_cons(make_ordinary("IEEE-FLOATING-POINT"),
  196.                      make_cons(make_ordinary("UNIX"),
  197.                      make_cons(make_ordinary("BSD"),
  198.                      make_cons(make_ordinary("COMMON"),
  199.                      make_cons(make_ordinary("IBCL"), Cnil))))))));
  200. ----------
  201. to
  202. ----------
  203.         make_special("*FEATURES*",
  204.                      make_cons(make_ordinary("SUN4"),
  205.                      make_cons(make_ordinary("SPARC"),
  206.                      make_cons(make_ordinary("IEEE-FLOATING-POINT"),
  207.                      make_cons(make_ordinary("UNIX"),
  208.                      make_cons(make_ordinary("BSD"),
  209.                      make_cons(make_ordinary("COMMON"),
  210.                      make_cons(make_ordinary("IBCL"),
  211.                      make_cons(make_keyword("TURBO-CLOSURE"),
  212.                      make_cons(make_keyword("TURBO-CLOSURE-ENV-SIZE"),
  213.                      Cnil))))))))));
  214. ----------
  215. But, if the C macro ADD_FEATURE is defined at the end of main.c,
  216. use it instead.
  217. Insert the lines:
  218.         ADD_FEATURE("TURBO-CLOSURE");
  219.         ADD_FEATURE("TURBO-CLOSURE-ENV-SIZE");
  220. After the line:
  221.         ADD_FEATURE("AKCL");